package jpane;

import java.awt.*; import java.applet.*;
public class NestedApplet extends Applet
{
  int width=400; int height=200; // display params
  int level=100; int inc=10;     // nesting defaults
  // first override the life cycle methods
  public void init()
  {System.out.println("Initializing");incNesting();}
  public void start()
  {System.out.println("Starting.");incNesting();}
  public void stop()
  {System.out.println("Stopping.");incNesting();}
  public void destroy()
  {System.out.println("Shutting down.");incNesting();}
  public void paint(Graphics g)
  {
    int i, shift=0; g.setColor(Color.blue);
    for (i=0;i<level;i++)
    {
      g.drawRect(shift,shift,width-2*shift-1,height-2*shift-1);
      shift = shift + inc;
    }
    g.drawString("Nesting level = "+level,width/2-50,height/2+5);
  }
  public void incNesting() {level++;repaint();}
}